<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>js改变样式</title>
    <style>
        #outer{
            transition: all 1s;
        }
        .c2{
            background-color: #000;
            width: 100px;
            height: 100px;
        }

        .c1{
            background-color: yellow;
            width: 200px;
            height: 200px;
        }
    </style>
</head>
<body>
    <button type="button" onclick="change_color()">改变背景</button>

    <div id="outer" class="c2">

    </div>

    <script>
        function change_color(){
            //散列的写法 - 不推荐
            let div = document.getElementById("outer");

            //css代码和js代码出现了耦合
            //js如何操作css
            // div.style.backgroundColor="yellow";
            // div.style.width=200+"px";
            // div.style.height=200+"px";

            div.className="c1";
        }
    </script>
</body>
</html>